snapshot: Handle transparent opacity nodes correctly
authorMatthias Clasen <mclasen@redhat.com>
Thu, 15 Jul 2021 17:14:13 +0000 (13:14 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 15 Jul 2021 17:18:23 +0000 (13:18 -0400)
Eliding totally transparent content from the node tree is
not 100% correct, since filters can make things visible, so
we need to at least preserve the bounds. We can do that by
creating a transparent color node.

gtk/gtksnapshot.c

index b0b1222c6665166746a236ef4c00424434367bd9..ad5533982a0e21c20edfba65be53427462717d58 100644 (file)
@@ -30,6 +30,8 @@
 #include "gtkstylecontextprivate.h"
 #include "gsktransformprivate.h"
 
+#include "gdk/gdkrgbaprivate.h"
+
 #include "gsk/gskrendernodeprivate.h"
 #include "gsk/gskroundedrectprivate.h"
 
@@ -461,8 +463,12 @@ gtk_snapshot_collect_opacity (GtkSnapshot      *snapshot,
     }
   else if (state->data.opacity.opacity == 0.0)
     {
+      GdkRGBA color = GDK_RGBA ("00000000");
+      graphene_rect_t bounds;
+
+      gsk_render_node_get_bounds (node, &bounds);
+      opacity_node = gsk_color_node_new (&color, &bounds);
       gsk_render_node_unref (node);
-      opacity_node = NULL;
     }
   else
     {